package com.example.babydatacollector;

import com.example.babydatacollector.EventContract.Event;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class EventDbHelper extends SQLiteOpenHelper {
	// If you change the database schema, you must increment the database
	// version.
	public static final int DATABASE_VERSION = 1;
	public static final String DATABASE_NAME = "Event.db";

	private static final String SQL_CREATE_TABLE = "CREATE TABLE "
			+ Event.TABLE_NAME + " (" + Event._ID + " INTEGER PRIMARY KEY, "
			+ Event.COLUMN_NAME_TYPE + " TEXT, " + Event.COLUMN_NAME_START_TIME
			+ " INTEGER, " + Event.COLUMN_NAME_END_TIME + " INTEGER)";
	private static final String SQL_DROP_TABLE = "DROP TABLE IF EXISTS "
			+ Event.TABLE_NAME;

	public EventDbHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(SQL_DROP_TABLE);
		db.execSQL(SQL_CREATE_TABLE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		throw new UnsupportedOperationException();
	}

}
